<?php 
	header("Content-Type: text/html;charset=utf-8");
	$username = $_POST['userid'];
	$password = $_POST['userpwd'];
	
try{
	$pdo = new PDO('mysql:local=localhost;dbname=exercise', 'root', 'root');
	$sql = 'select * from member';
	$sql2 = 'set names utf8';
	$pdo->query($sql2);
	//prepare($sql)； 准备一条SQl语句。
	$stmt = $pdo->prepare($sql);
	//execute(); 执行一条预处理语句
	$res = $stmt->execute();
	if($res) {
		while($row = $stmt->fetch()) {
			if(($username==$row['idnumber'])&&($password==$row['password'])){
				echo"欢迎你,".$row['name'];
				break;
			}
			else{
				echo "用户名不存在！！！";
			}
		}
	}else{
		echo"该数据为空！";
	}
}catch(PDOException $e) {
	echo $e->getMessage();
}

 ?>